import time
import pygame
import random

WIDTH = 360
HEIGHT = 480
FPS = 30
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
myfont = pygame.font.Font(None,60)
textImage = myfont.render("pygame", True, WHITE)
running = True
count = 0
start = time.time()
while running:
    clock.tick(FPS)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    count+=1
    now = time.time()
    fps = count/(now-start)
    fpsImage = myfont.render(str(fps), True, WHITE)
    screen.fill(BLACK)
    screen.blit(fpsImage, (10, 100))
    pygame.display.flip()

pygame.quit()
